import numpy as np
from keras.models import load_model
from keras.preprocessing.image import load_img
from keras.preprocessing import image
import matplotlib.pyplot as plt
import cv2




# 加载权重
model = load_model('my_model.h5')

# 加载图像
img = load_img('dog1.png',target_size=(224, 224))
img = image.img_to_array(img) / 255.0
img = np.expand_dims(img, axis=0)


predictions= model.predict(img)
result = np.squeeze(model.predict(img))
predict_class = np.argmax(result)
print (predictions)
print ('猫的概率 %.6f' %predictions [:,0])
print ('狗的概率 %.6f' %predictions [:,1])
